package com.codemes.happylist.lucene.analyzer;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;

/**
 * @author <a href="mail:fulei@fehorizon.com">fulei</a>
 * @date 2022/8/23 8:46
 */
public class IKAnalyzer  extends Analyzer {

    private boolean useSmart;

    public boolean useSmart() {
        return this.useSmart;
    }

    public void setUseSmart(boolean useSmart) {
        this.useSmart = useSmart;
    }

    public IKAnalyzer() {
        this(false);
    }
    public IKAnalyzer(boolean useSmart) {
        this.useSmart = useSmart;
    }
    @Override
    protected TokenStreamComponents createComponents(String s) {
        Tokenizer ikTokenizer = new IKTokenizer(this.useSmart());
        return new Analyzer.TokenStreamComponents(ikTokenizer);
    }
}
